﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GRC_TPE_WebApp.Controller;

namespace GRC_TPE_WebApp.View.Private.User
{
    public partial class ListUsers : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Méthode déclenchée au clic sur le bouton de modification
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Update_button_Click(object sender, EventArgs e)
        {
            String idUser = (String)((Button)sender).CommandArgument;
            Response.Redirect("EditUser.aspx?id=" + idUser);
        }

        /// <summary>
        /// Méthode déclenchée au clic sur le bouton d'ajout d'un Utilisateur
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void B_AddUser_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/View/Private/User/AddUser.aspx");
        }

        /// <summary>
        /// Méthode déclenchée au clic sur le bouton de suppression
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void B_Delete_Click(object sender, EventArgs e)
        {
            String ids = (String)((Button)sender).CommandArgument;
            int id = int.Parse(ids);
            if (UserController.DeleteUser(id) == "No error")
                Response.Redirect("ListUsers.aspx");
        }
    }
}